package com.TIEmulator;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class CheckBoxifiedTextListAdapter extends BaseAdapter
  implements CompoundButton.OnCheckedChangeListener
{
  private Context mContext;
  private List<CheckBoxifiedText> mItems = new ArrayList();

  public CheckBoxifiedTextListAdapter(Context paramContext)
  {
    this.mContext = paramContext;
  }

  public void addItem(String paramString)
  {
    this.mItems.add(new CheckBoxifiedText(paramString, false));
  }

  public boolean areAllItemsSelectable()
  {
    return false;
  }

  public void deselectAll()
  {
    Iterator localIterator = this.mItems.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        notifyDataSetInvalidated();
        return;
      }
      ((CheckBoxifiedText)localIterator.next()).setChecked(false);
    }
  }

  public int getCount()
  {
    return this.mItems.size();
  }

  public Object getItem(int paramInt)
  {
    return this.mItems.get(paramInt);
  }

  public long getItemId(int paramInt)
  {
    return paramInt;
  }

  public View getView(int paramInt, View paramView, ViewGroup paramViewGroup)
  {
    CheckBoxifiedText localCheckBoxifiedText = (CheckBoxifiedText)this.mItems.get(paramInt);
    if (paramView == null);
    for (View localView = ((LayoutInflater)this.mContext.getSystemService("layout_inflater")).inflate(2130903043, null); ; localView = paramView)
    {
      CheckBox localCheckBox = (CheckBox)localView.findViewById(2131296275);
      localCheckBox.setChecked(localCheckBoxifiedText.getChecked());
      localCheckBox.setOnCheckedChangeListener(this);
      localCheckBox.setId(paramInt);
      TextView localTextView = (TextView)localView.findViewById(2131296276);
      localCheckBox.setChecked(localCheckBoxifiedText.getChecked());
      localTextView.setText(localCheckBoxifiedText.getText());
      return localView;
    }
  }

  public void onCheckedChanged(CompoundButton paramCompoundButton, boolean paramBoolean)
  {
    StringBuilder localStringBuilder = new StringBuilder("=====> onCheckedChanged: button id: ").append(paramCompoundButton.getId()).append(" is ");
    String str;
    if (paramBoolean)
    {
      str = "checked";
      label30: Log.i("", str);
      if (!(this.mContext instanceof ItemClick))
        break label80;
      ((ItemClick)this.mContext).onCheckBoxifiedTextItemClicked(paramCompoundButton.getId(), paramBoolean);
    }
    while (true)
    {
      return;
      str = "UNchecked";
      break label30:
      label80: Log.w("", "I'm sorry but the Context is no instance of ItemClick");
    }
  }

  public void selectAll()
  {
    Iterator localIterator = this.mItems.iterator();
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        notifyDataSetInvalidated();
        return;
      }
      ((CheckBoxifiedText)localIterator.next()).setChecked(true);
    }
  }

  public void setChecked(boolean paramBoolean, int paramInt)
  {
    ((CheckBoxifiedText)this.mItems.get(paramInt)).setChecked(paramBoolean);
  }

  public void setListItems(List<CheckBoxifiedText> paramList)
  {
    this.mItems = paramList;
  }

  public static abstract interface ItemClick
  {
    public abstract void onCheckBoxifiedTextItemClicked(int paramInt, boolean paramBoolean);
  }
}
